package com.xjtu.controller;


import com.xjtu.config.SocketManager;
import com.xjtu.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.Set;


@Controller
@RestController
@RequestMapping("/call")
public class CallController {

    @GetMapping("/online")
    public Map<String, User> onlineList() {
        return SocketManager.listUser();
    }

    @GetMapping("/isOnline")
    public boolean isOnline(String deviceId) {
        User user = SocketManager.getUser(deviceId);
        return user != null;
    }
}
